//
//  UIImage+Image.m
//  RunTime
//
//  Created by 吴志勇 on 2020/3/21.
//  Copyright © 2020 wzy. All rights reserved.
//

#import "UIImage+Image.h"
#import <objc/message.h>

#if TARGET_OS_MACCATALYST
    #import <AppKit/AppKit.h>
#endif


@implementation UIImage (Image)
//把类加载进内存的时候调用，只会调用一次
+(void)load{
    //获取imageNamed
    Method imageNameMethod =  class_getClassMethod(self, @selector(imageNamed:));
    //获取wzy_imageNamed
    Method wzy_imageNameMethod = class_getClassMethod(self, @selector(wzy_imageNamed:));
    //交换方法
    method_exchangeImplementations(imageNameMethod, wzy_imageNameMethod);
}
//d调用多次
//+ (void)initialize
//{
//
//}

+ (UIImage *)wzy_imageNamed:(NSString *)name{
    UIImage *image = [UIImage wzy_imageNamed:name];
    if (image) {
        NSLog(@"成功");
    }else{
        NSLog(@"失败");
    }
    
    return image;
}
@end
